package org.codersunit.radboid.test;

import java.util.Map;

public class ListElementsParser extends HtmlParser {
	
	private String eventValidation = null;
	private String viewState = null;
	
	public String getEventValidation() {
		return eventValidation;
	}
	
	public String getViewState() {
		return viewState;
	}

	@Override
	protected void handleEndElement(String name) {
		//Log.d("RadboidTest", String.format("END_ELEM: '%s'", name));
	}

	@Override
	protected void handleStartElement(String name, Map<String, String> attrs,
			boolean selfClosed) {		
		if(name.equals("input") && "__VIEWSTATE".equals(attrs.get("name"))) {
			viewState = attrs.get("value");
		}
		
		if(name.equals("input") && "__EVENTVALIDATION".equals(attrs.get("name"))) {
			eventValidation = attrs.get("value");
		}
		
		if(viewState != null && eventValidation != null) {
			stop();
		}
	}

	@Override
	protected void handleText(String text) {
		//Log.d("RadboidTest", String.format("TXT_ELEM: %s", text));
	}

	@Override
	protected void handleComment(String comment) {
		//Log.d("RadboidTest", String.format("CMT_ELEM: %s", comment));
	}

	@Override
	protected void handleDoctype(String doctype) {
		//Log.d("RadboidTest", String.format("DOC_ELEM: %s", doctype));
	}

}
